//
//  KlineViewModel.m
//  Futures
//
//  Created by Cheng on 2017/6/23.
//  Copyright © 2017年 Cheng. All rights reserved.
//

#import "KlineViewModel.h"
#import "KlineModel.h"

@implementation KlineViewModel
//传参：symbol,exchange,starttime,datatype
+ (void)requestKlineDataWithSymbol:(NSString *)symbol exchange:(NSString *)exchange starttime:(NSString *)starttime datatype:(NSString *)datatype block:(void (^)(NSMutableArray *klineArray))block{
    NSMutableArray *array = [NSMutableArray array];
    [Network requestDataMethod:GET WithUrl:URL_H_DATA parameters:@{@"symbol":symbol,
                                                                  @"exchange":exchange,
                                                                  @"starttime":starttime,
                                                                  @"datatype":datatype} success:^(NSURLSessionDataTask *task, id responseObject) {
                                                                      NSArray *arr = responseObject;
                                                                      [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                                                                          KlineModel *model = [[KlineModel alloc] initWithDict:obj];
                                                                          [array addObject:model];
                                                                      }];
                                                                      block(array);
                                                                  } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                                                      
                                                                  }];
}
@end
